package com.yc.study.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yc.study.entity.CourseMaterials;
import com.yc.study.service.ICourseMaterialsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课程资料信息 前端控制器
 *
 * @author 王妍
 * @since 2022-04-10
 */
@RestController
@RequestMapping("/study/courseMaterials")
public class CourseMaterialsController {

  @Autowired private ICourseMaterialsService courseMaterialsService;

  @GetMapping("course/{courseId}")
  public List<CourseMaterials> getCourseMaterials(@PathVariable Long courseId) {
    return courseMaterialsService.list(
        new LambdaQueryWrapper<CourseMaterials>().eq(CourseMaterials::getCourseId, courseId));
  }
}
